﻿using DevExpress.XtraGrid.Views.BandedGrid;
using DLL;
using NursingFormSystem.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NursingFormSystem.NursingRecordsIntegration
{
    public partial class HistoryNursingRecordsIntegration : Form
    {
        public NursingFormSystem.NurFormsService.NursingForm formService = new NursingFormSystem.NurFormsService.NursingForm();
        PatientInfo PatientInfo;
        Tb_User LoginUser;
        public HistoryNursingRecordsIntegration(Tb_User loginUser, PatientInfo patientInfo)
        {
            InitializeComponent();
            this.PatientInfo = patientInfo;
            this.LoginUser = loginUser;
            LoadData("", "");
            SetBandGridView();
        }

        #region LoadData显示
        private void LoadData(string StatDate, string EndDate)
        {
            string patientid = this.PatientInfo.PATIENT_ID;//住院号
            int VisitId = this.PatientInfo.VISIT_ID;//住院次数
            int FormId = (int)FormType.NursingRecordsIntegration;//18009  //表单ID
            StringBuilder sql = new StringBuilder(@"SELECT  * , '' AS riqi, 
             '' AS shengmingtizhengT1,  '' AS shengmingtizhengT2,  '' AS shengmingtizhengT3,  '' AS shengmingtizhengT4,  
             '' AS shengmingtizhengT5,  '' AS shengmingtizhengT6,  '' AS shengmingtizhengT7,  '' AS shengmingtizhengT8,  
             '' AS shengmingtizhengT9,  '' AS shengmingtizhengT10,  '' AS shengmingtizhengT11,  '' AS shengmingtizhengT12, 
             ''AS shengmingtizhengHR1, ''AS shengmingtizhengHR2, ''AS shengmingtizhengHR3, ''AS shengmingtizhengHR4, 
             ''AS shengmingtizhengHR5, ''AS shengmingtizhengHR6, ''AS shengmingtizhengHR7, ''AS shengmingtizhengHR8, 
             ''AS shengmingtizhengHR9, ''AS shengmingtizhengHR10, ''AS shengmingtizhengHR11, ''AS shengmingtizhengHR12,
             ''AS shengmingtizhengR1, ''AS shengmingtizhengR2, ''AS shengmingtizhengR3, ''AS shengmingtizhengR4, 
             ''AS shengmingtizhengR5, ''AS shengmingtizhengR6, ''AS shengmingtizhengR7, ''AS shengmingtizhengR8,
             ''AS shengmingtizhengR9, ''AS shengmingtizhengR10, ''AS shengmingtizhengR11, ''AS shengmingtizhengR12,
             ''AS shengmingtizhengBP1, ''AS shengmingtizhengBP2, ''AS shengmingtizhengBP3, ''AS shengmingtizhengBP4, 
             ''AS shengmingtizhengBP5, ''AS shengmingtizhengBP6, ''AS shengmingtizhengBP7, ''AS shengmingtizhengBP8, 
             ''AS shengmingtizhengBP9, ''AS shengmingtizhengBP10, ''AS shengmingtizhengBP11, ''AS shengmingtizhengBP12,
             ''AS shengmingtizhengSP1, ''AS shengmingtizhengSP2, ''AS shengmingtizhengSP3, ''AS shengmingtizhengSP4, 
             ''AS shengmingtizhengSP5, ''AS shengmingtizhengSP6, ''AS shengmingtizhengSP7, ''AS shengmingtizhengSP8, 
             ''AS shengmingtizhengSP9, ''AS shengmingtizhengSP10, ''AS shengmingtizhengSP11, ''AS shengmingtizhengSP12,
             '' AS yishizhuangtai1, '' AS yishizhuangtai2,'' AS yishizhuangtai3, '' AS yishizhuangtai4, 
             '' AS yishizhuangtai5, '' AS yishizhuangtai6,'' AS yishizhuangtai7, '' AS yishizhuangtai8, 
             '' AS yishizhuangtai9, '' AS yishizhuangtai10, '' AS yishizhuangtai11, '' AS yishizhuangtai12,
             '' AS wuhua1, '' AS wuhua2,  '' AS wuhua3, '' AS wuhua4,  '' AS wuhua5,  '' AS wuhua6,  
             '' AS wuhua7, '' AS wuhua8,  '' AS wuhua9, '' AS wuhua10,  '' AS wuhua11,  '' AS wuhua12,
             '' AS jichuhuli1, '' AS jichuhuli2, '' AS jichuhuli3, '' AS jichuhuli4, '' AS jichuhuli5, '' AS jichuhuli6, 
             '' AS jichuhuli7, '' AS jichuhuli8,'' AS jichuhuli9, '' AS jichuhuli10, '' AS jichuhuli11, '' AS jichuhuli12,
             '' AS niaoliang1, '' AS niaoliang2, '' AS niaoliang3, '' AS niaoliang4, '' AS niaoliang5, '' AS niaoliang6, 
             '' AS niaoliang7, '' AS niaoliang8, '' AS niaoliang9, '' AS niaoliang10, '' AS niaoliang11, '' AS niaoliang12,
             '' AS chuliangqita1, '' AS chuliangqita2, '' AS chuliangqita3, '' AS chuliangqita4, '' AS chuliangqita5, 
             '' AS chuliangqita6, '' AS chuliangqita7, '' AS chuliangqita8, '' AS chuliangqita9, '' AS chuliangqita10, 
             '' AS chuliangqita11, '' AS chuliangqita12, '' AS chuliangqita13, '' AS chuliangqita14, '' AS chuliangqita15,
             '' AS chuliangqita16, '' AS chuliangqita17, '' AS chuliangqita18, '' AS chuliangqita19, '' AS chuliangqita20,
             '' AS chuliangqita21, '' AS chuliangqita22, '' AS chuliangqita23, '' AS chuliangqita24,
             '' AS bingqingjicuoshi1, '' AS bingqingjicuoshi2,'' AS bingqingjicuoshi3, 
             '' AS zongruliang, '' AS weichangluliang, '' AS jingmailuliang, '' AS zongruliangqita,
             '' AS zongchuliang, '' AS niaoliang, '' AS dabian, '' AS niaofenhunhe, '' AS zongchuliangqita,
             '' AS hushiqianming1, '' AS hushiqianming2, '' AS hushiqianming3 FROM    dbo.NursingFormRecord(NOLOCK) ");
            sql.AppendFormat("WHERE FormId = '{0}'", FormId);
            sql.AppendFormat(" AND patientid = '{0}' ", patientid);
            sql.AppendFormat(" AND VisitId = '{0}' ", VisitId);
            if (!string.IsNullOrEmpty(StatDate)) sql.AppendFormat(" AND AssessmentDate >= '{0}' ", StatDate + " 00:00:00");
            if (!string.IsNullOrEmpty(EndDate)) sql.AppendFormat(" AND AssessmentDate <= '{0}' ", EndDate + " 23:59:59");
            sql.Append(" ORDER BY [AssessmentDate] DESC");
            DataTable dt = (SqlHelper.ExecuteDataset(sql.ToString(), CommandType.Text)).Tables[0];
            if (dt.Rows.Count <= 0) return;
            DataTable dtt = dt.Clone();
            //string theTrue = "√";
            foreach (DataRow dr in dt.Rows)
            {
                var NursingFormData = Convert.ToString(dr["NursingFormData"]);
                NursingFormSystem.Model.NursingRecordsIntegration fd = new NursingFormSystem.Model.NursingRecordsIntegration();
                fd = XmlUtil.XMLToObject<NursingFormSystem.Model.NursingRecordsIntegration>(NursingFormData, Encoding.UTF8);
                DataRow newRow = dtt.NewRow();
                newRow["riqi"] = fd.RiQi;
                #region 生命体征
                if (!string.IsNullOrEmpty(fd.ShengMingTiZheng.T))
                {
                    string ysgj_yf = fd.ShengMingTiZheng.T.IndexOf("#") < 0 ? "###########" : fd.ShengMingTiZheng.T;
                    string[] ysgj_yf_arrary = ysgj_yf.Split('#');
                    if (ysgj_yf_arrary.Length >= 12)
                    {
                        newRow["shengmingtizhengT1"] = ysgj_yf_arrary[0];
                        newRow["shengmingtizhengT2"] = ysgj_yf_arrary[1];
                        newRow["shengmingtizhengT3"] = ysgj_yf_arrary[2];
                        newRow["shengmingtizhengT4"] = ysgj_yf_arrary[3];
                        newRow["shengmingtizhengT5"] = ysgj_yf_arrary[4];
                        newRow["shengmingtizhengT6"] = ysgj_yf_arrary[5];
                        newRow["shengmingtizhengT7"] = ysgj_yf_arrary[6];
                        newRow["shengmingtizhengT8"] = ysgj_yf_arrary[7];
                        newRow["shengmingtizhengT9"] = ysgj_yf_arrary[8];
                        newRow["shengmingtizhengT10"] = ysgj_yf_arrary[9];
                        newRow["shengmingtizhengT11"] = ysgj_yf_arrary[10];
                        newRow["shengmingtizhengT12"] = ysgj_yf_arrary[11];
                    }
                }
                if (!string.IsNullOrEmpty(fd.ShengMingTiZheng.HR))
                {
                    string ysgj_yf = fd.ShengMingTiZheng.HR.IndexOf("#") < 0 ? "###########" : fd.ShengMingTiZheng.HR;
                    string[] ysgj_yf_arrary = ysgj_yf.Split('#');
                    if (ysgj_yf_arrary.Length >= 12)
                    {
                        newRow["shengmingtizhengHR1"] = ysgj_yf_arrary[0];
                        newRow["shengmingtizhengHR2"] = ysgj_yf_arrary[1];
                        newRow["shengmingtizhengHR3"] = ysgj_yf_arrary[2];
                        newRow["shengmingtizhengHR4"] = ysgj_yf_arrary[3];
                        newRow["shengmingtizhengHR5"] = ysgj_yf_arrary[4];
                        newRow["shengmingtizhengHR6"] = ysgj_yf_arrary[5];
                        newRow["shengmingtizhengHR7"] = ysgj_yf_arrary[6];
                        newRow["shengmingtizhengHR8"] = ysgj_yf_arrary[7];
                        newRow["shengmingtizhengHR9"] = ysgj_yf_arrary[8];
                        newRow["shengmingtizhengHR10"] = ysgj_yf_arrary[9];
                        newRow["shengmingtizhengHR11"] = ysgj_yf_arrary[10];
                        newRow["shengmingtizhengHR12"] = ysgj_yf_arrary[11];
                    }
                }
                if (!string.IsNullOrEmpty(fd.ShengMingTiZheng.R))
                {
                    string ysgj_yf = fd.ShengMingTiZheng.R.IndexOf("#") < 0 ? "###########" : fd.ShengMingTiZheng.R;
                    string[] ysgj_yf_arrary = ysgj_yf.Split('#');
                    if (ysgj_yf_arrary.Length >= 12)
                    {
                        newRow["shengmingtizhengR1"] = ysgj_yf_arrary[0];
                        newRow["shengmingtizhengR2"] = ysgj_yf_arrary[1];
                        newRow["shengmingtizhengR3"] = ysgj_yf_arrary[2];
                        newRow["shengmingtizhengR4"] = ysgj_yf_arrary[3];
                        newRow["shengmingtizhengR5"] = ysgj_yf_arrary[4];
                        newRow["shengmingtizhengR6"] = ysgj_yf_arrary[5];
                        newRow["shengmingtizhengR7"] = ysgj_yf_arrary[6];
                        newRow["shengmingtizhengR8"] = ysgj_yf_arrary[7];
                        newRow["shengmingtizhengR9"] = ysgj_yf_arrary[8];
                        newRow["shengmingtizhengR10"] = ysgj_yf_arrary[9];
                        newRow["shengmingtizhengR11"] = ysgj_yf_arrary[10];
                        newRow["shengmingtizhengR12"] = ysgj_yf_arrary[11];
                    }
                }
                if (!string.IsNullOrEmpty(fd.ShengMingTiZheng.BP))
                {
                    string ysgj_yf = fd.ShengMingTiZheng.BP.IndexOf("#") < 0 ? "###########" : fd.ShengMingTiZheng.BP;
                    string[] ysgj_yf_arrary = ysgj_yf.Split('#');
                    if (ysgj_yf_arrary.Length >= 12)
                    {
                        newRow["shengmingtizhengBP1"] = ysgj_yf_arrary[0];
                        newRow["shengmingtizhengBP2"] = ysgj_yf_arrary[1];
                        newRow["shengmingtizhengBP3"] = ysgj_yf_arrary[2];
                        newRow["shengmingtizhengBP4"] = ysgj_yf_arrary[3];
                        newRow["shengmingtizhengBP5"] = ysgj_yf_arrary[4];
                        newRow["shengmingtizhengBP6"] = ysgj_yf_arrary[5];
                        newRow["shengmingtizhengBP7"] = ysgj_yf_arrary[6];
                        newRow["shengmingtizhengBP8"] = ysgj_yf_arrary[7];
                        newRow["shengmingtizhengBP9"] = ysgj_yf_arrary[8];
                        newRow["shengmingtizhengBP10"] = ysgj_yf_arrary[9];
                        newRow["shengmingtizhengBP11"] = ysgj_yf_arrary[10];
                        newRow["shengmingtizhengBP12"] = ysgj_yf_arrary[11];
                    }
                }
                if (!string.IsNullOrEmpty(fd.ShengMingTiZheng.SPO2))
                {
                    string ysgj_yf = fd.ShengMingTiZheng.SPO2.IndexOf("#") < 0 ? "###########" : fd.ShengMingTiZheng.SPO2;
                    string[] ysgj_yf_arrary = ysgj_yf.Split('#');
                    if (ysgj_yf_arrary.Length >= 12)
                    {
                        newRow["shengmingtizhengSP1"] = ysgj_yf_arrary[0];
                        newRow["shengmingtizhengSP2"] = ysgj_yf_arrary[1];
                        newRow["shengmingtizhengSP3"] = ysgj_yf_arrary[2];
                        newRow["shengmingtizhengSP4"] = ysgj_yf_arrary[3];
                        newRow["shengmingtizhengSP5"] = ysgj_yf_arrary[4];
                        newRow["shengmingtizhengSP6"] = ysgj_yf_arrary[5];
                        newRow["shengmingtizhengSP7"] = ysgj_yf_arrary[6];
                        newRow["shengmingtizhengSP8"] = ysgj_yf_arrary[7];
                        newRow["shengmingtizhengSP9"] = ysgj_yf_arrary[8];
                        newRow["shengmingtizhengSP10"] = ysgj_yf_arrary[9];
                        newRow["shengmingtizhengSP11"] = ysgj_yf_arrary[10];
                        newRow["shengmingtizhengSP12"] = ysgj_yf_arrary[11];
                    }
                }
                #endregion
                #region 意识状态
                if (!string.IsNullOrEmpty(fd.YiShi.YiShiZhuangTai))
                {
                    string ysgj_yf = fd.YiShi.YiShiZhuangTai.IndexOf("#") < 0 ? "###########" : fd.YiShi.YiShiZhuangTai;
                    string[] ysgj_yf_arrary = ysgj_yf.Split('#');
                    if (ysgj_yf_arrary.Length >= 12)
                    {
                        newRow["yishizhuangtai1"] = ysgj_yf_arrary[0];
                        newRow["yishizhuangtai2"] = ysgj_yf_arrary[1];
                        newRow["yishizhuangtai3"] = ysgj_yf_arrary[2];
                        newRow["yishizhuangtai4"] = ysgj_yf_arrary[3];
                        newRow["yishizhuangtai5"] = ysgj_yf_arrary[4];
                        newRow["yishizhuangtai6"] = ysgj_yf_arrary[5];
                        newRow["yishizhuangtai7"] = ysgj_yf_arrary[6];
                        newRow["yishizhuangtai8"] = ysgj_yf_arrary[7];
                        newRow["yishizhuangtai9"] = ysgj_yf_arrary[8];
                        newRow["yishizhuangtai10"] = ysgj_yf_arrary[9];
                        newRow["yishizhuangtai11"] = ysgj_yf_arrary[10];
                        newRow["yishizhuangtai12"] = ysgj_yf_arrary[11];
                    }
                }
                #endregion
                #region 护理
                if (!string.IsNullOrEmpty(fd.HuLi.WuHua))
                {
                    string ysgj_yf = fd.HuLi.WuHua.IndexOf("#") < 0 ? "###########" : fd.HuLi.WuHua;
                    string[] ysgj_yf_arrary = ysgj_yf.Split('#');
                    if (ysgj_yf_arrary.Length >= 12)
                    {
                        newRow["wuhua1"] = ysgj_yf_arrary[0];
                        newRow["wuhua2"] = ysgj_yf_arrary[1];
                        newRow["wuhua3"] = ysgj_yf_arrary[2];
                        newRow["wuhua4"] = ysgj_yf_arrary[3];
                        newRow["wuhua5"] = ysgj_yf_arrary[4];
                        newRow["wuhua6"] = ysgj_yf_arrary[5];
                        newRow["wuhua7"] = ysgj_yf_arrary[6];
                        newRow["wuhua8"] = ysgj_yf_arrary[7];
                        newRow["wuhua9"] = ysgj_yf_arrary[8];
                        newRow["wuhua10"] = ysgj_yf_arrary[9];
                        newRow["wuhua11"] = ysgj_yf_arrary[10];
                        newRow["wuhua12"] = ysgj_yf_arrary[11];
                    }
                }
                if (!string.IsNullOrEmpty(fd.HuLi.JiChuHuLi))
                {
                    string ysgj_yf = fd.HuLi.JiChuHuLi.IndexOf("#") < 0 ? "###########" : fd.HuLi.JiChuHuLi;
                    string[] ysgj_yf_arrary = ysgj_yf.Split('#');
                    if (ysgj_yf_arrary.Length >= 12)
                    {
                        newRow["jichuhuli1"] = ysgj_yf_arrary[0];
                        newRow["jichuhuli2"] = ysgj_yf_arrary[1];
                        newRow["jichuhuli3"] = ysgj_yf_arrary[2];
                        newRow["jichuhuli4"] = ysgj_yf_arrary[3];
                        newRow["jichuhuli5"] = ysgj_yf_arrary[4];
                        newRow["jichuhuli6"] = ysgj_yf_arrary[5];
                        newRow["jichuhuli7"] = ysgj_yf_arrary[6];
                        newRow["jichuhuli8"] = ysgj_yf_arrary[7];
                        newRow["jichuhuli9"] = ysgj_yf_arrary[8];
                        newRow["jichuhuli10"] = ysgj_yf_arrary[9];
                        newRow["jichuhuli11"] = ysgj_yf_arrary[10];
                        newRow["jichuhuli12"] = ysgj_yf_arrary[11];
                    }
                }
                #endregion
                #region 出量
                if (!string.IsNullOrEmpty(fd.ChuLiang.NiaoLiang))
                {
                    string ysgj_yf = fd.ChuLiang.NiaoLiang.IndexOf("#") < 0 ? "###########" : fd.ChuLiang.NiaoLiang;
                    string[] ysgj_yf_arrary = ysgj_yf.Split('#');
                    if (ysgj_yf_arrary.Length >= 12)
                    {
                        newRow["niaoliang1"] = ysgj_yf_arrary[0];
                        newRow["niaoliang2"] = ysgj_yf_arrary[1];
                        newRow["niaoliang3"] = ysgj_yf_arrary[2];
                        newRow["niaoliang4"] = ysgj_yf_arrary[3];
                        newRow["niaoliang5"] = ysgj_yf_arrary[4];
                        newRow["niaoliang6"] = ysgj_yf_arrary[5];
                        newRow["niaoliang7"] = ysgj_yf_arrary[6];
                        newRow["niaoliang8"] = ysgj_yf_arrary[7];
                        newRow["niaoliang9"] = ysgj_yf_arrary[8];
                        newRow["niaoliang10"] = ysgj_yf_arrary[9];
                        newRow["niaoliang11"] = ysgj_yf_arrary[10];
                        newRow["niaoliang12"] = ysgj_yf_arrary[11];
                    }
                }
                if (!string.IsNullOrEmpty(fd.ChuLiang.QiTa))
                {
                    string ysgj_yf = fd.ChuLiang.QiTa.IndexOf("#") < 0 ? "#######################" : fd.ChuLiang.QiTa;
                    string[] ysgj_yf_arrary = ysgj_yf.Split('#');
                    if (ysgj_yf_arrary.Length >= 24)
                    {
                        newRow["chuliangqita1"] = ysgj_yf_arrary[0];
                        newRow["chuliangqita2"] = ysgj_yf_arrary[1];
                        newRow["chuliangqita3"] = ysgj_yf_arrary[2];
                        newRow["chuliangqita4"] = ysgj_yf_arrary[3];
                        newRow["chuliangqita5"] = ysgj_yf_arrary[4];
                        newRow["chuliangqita6"] = ysgj_yf_arrary[5];
                        newRow["chuliangqita7"] = ysgj_yf_arrary[6];
                        newRow["chuliangqita8"] = ysgj_yf_arrary[7];
                        newRow["chuliangqita9"] = ysgj_yf_arrary[8];
                        newRow["chuliangqita10"] = ysgj_yf_arrary[9];
                        newRow["chuliangqita11"] = ysgj_yf_arrary[10];
                        newRow["chuliangqita12"] = ysgj_yf_arrary[11];
                        newRow["chuliangqita13"] = ysgj_yf_arrary[12];
                        newRow["chuliangqita14"] = ysgj_yf_arrary[13];
                        newRow["chuliangqita15"] = ysgj_yf_arrary[14];
                        newRow["chuliangqita16"] = ysgj_yf_arrary[15];
                        newRow["chuliangqita17"] = ysgj_yf_arrary[16];
                        newRow["chuliangqita18"] = ysgj_yf_arrary[17];
                        newRow["chuliangqita19"] = ysgj_yf_arrary[18];
                        newRow["chuliangqita20"] = ysgj_yf_arrary[19];
                        newRow["chuliangqita21"] = ysgj_yf_arrary[20];
                        newRow["chuliangqita22"] = ysgj_yf_arrary[21];
                        newRow["chuliangqita23"] = ysgj_yf_arrary[22];
                        newRow["chuliangqita24"] = ysgj_yf_arrary[23];
                    }
                }
                #endregion
                #region 病情措施
                newRow["bingqingjicuoshi1"] = fd.BingQingJiCuoShi;
                newRow["bingqingjicuoshi2"] = "";
                newRow["bingqingjicuoshi3"] = "";
                #endregion
                #region 出入量
                newRow["zongruliang"] = fd.ShiErXiaoShiChuRuLiang.ZongRuLiang;
                newRow["weichangluliang"] = fd.ShiErXiaoShiChuRuLiang.WeiChangRuLiang;
                newRow["jingmailuliang"] = fd.ShiErXiaoShiChuRuLiang.JingMaiRuLiang;
                newRow["zongruliangqita"] = fd.ShiErXiaoShiChuRuLiang.ZongRuLiangQiTa;
                newRow["zongchuliang"] = fd.ShiErXiaoShiChuRuLiang.ZongChuLiang;
                newRow["niaoliang"] = fd.ShiErXiaoShiChuRuLiang.NiaoLiang;
                newRow["dabian"] = fd.ShiErXiaoShiChuRuLiang.DaBian;
                newRow["niaofenhunhe"] = fd.ShiErXiaoShiChuRuLiang.NiaoFenJieHe;
                newRow["zongchuliangqita"] = fd.ShiErXiaoShiChuRuLiang.ZongChuLiangQiTa;
                #endregion
                #region 护士签名
                newRow["hushiqianming1"] = fd.HuShiQianMing;
                newRow["hushiqianming2"] = fd.HuShiQianMingShangYe;
                newRow["hushiqianming3"] = fd.HuShiQianMingXiaYe;
                #endregion
                //newRow["RiQi"] = string.IsNullOrEmpty(fd.RiQi) ? string.Empty : Convert.ToDateTime(fd.RiQi).ToString("yyyy-MM-dd");
                //ID隐藏，双击触发事件
                newRow["Id"] = dr["ID"];
                dtt.Rows.Add(newRow);
            }
            gridControl1.DataSource = dtt;
        }
        #endregion

        #region GridView设置
        //GridView设置
        private void SetBandGridView()
        {
            foreach (GridBand gridBand in this.bandedGridView1.Bands)//设置居中
            {
                foreach (GridBand gridBandSecond in gridBand.Children)
                {
                    gridBandSecond.OptionsBand.FixedWidth = true;
                    gridBandSecond.AppearanceHeader.Options.UseTextOptions = true;
                    gridBandSecond.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                    gridBandSecond.AppearanceHeader.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
                }
                gridBand.OptionsBand.FixedWidth = true;
                gridBand.AppearanceHeader.Options.UseTextOptions = true;
                gridBand.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                gridBand.AppearanceHeader.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
            }
        }
        #endregion


        #region 查询
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string StatDate = this.StatDate.Text;
            string EndDate = this.EndDate.Text;

            if (string.IsNullOrEmpty(StatDate) || string.IsNullOrEmpty(EndDate))
            {
                MessageBox.Show("查询日期不能为空！");
            }
            LoadData(StatDate, EndDate);
        }
        #endregion

        #region 新增
        private void btnAdd_Click(object sender, EventArgs e)
        {
            AddNursingRecordsIntegration addForm = new AddNursingRecordsIntegration(LoginUser, PatientInfo, string.Empty);
            addForm.ShowDialog();
            if (addForm.DialogResult == DialogResult.OK)
            {
                LoadData("", "");
            }
        }
        #endregion

        #region 修改
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (bandedGridView1.RowCount > 0)
            {
                string Id = bandedGridView1.GetRowCellValue(bandedGridView1.FocusedRowHandle, "Id").ToString();
                AddNursingRecordsIntegration addForm = new AddNursingRecordsIntegration(LoginUser, PatientInfo, Id);
                addForm.ShowDialog();
                if (addForm.DialogResult == DialogResult.OK)
                {
                    LoadData("", "");
                }
            }
        }
        #endregion

        #region 打印
        private void btnPrint_Click(object sender, EventArgs e)
        {
            //NursingRecordsIntegrationPrints f = new NursingRecordsIntegrationPrints(PatientInfo, StatDate.DateTime, EndDate.DateTime);
            //f.Show();
        }
        #endregion

        #region 删除
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要删除数据吗？", "删除前确认", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                string id = bandedGridView1.GetRowCellValue(bandedGridView1.FocusedRowHandle, "Id").ToString();
                var ret2 = formService.DeleteNursingFormRecord(id);
                MessageBox.Show(ret2.M);
                if (ret2.Code == 1)
                {
                    string dateStart = this.StatDate.Text;
                    string dateEnd = this.EndDate.Text;
                    LoadData(dateStart, dateEnd);
                }
            }
        }
        #endregion
    }
}
